package com.lzhsite.technology.designPattern.factory.TextImageReadDemo;

/**
 *  类描述：抽象工厂
 */
public abstract class AbstractFactory {
	/**
	 * 
	 * 方法说明：获取对应的读取对象
	 *
	 * @return
	 * @return IRead
	 */
	@SuppressWarnings("unchecked")
	public abstract IRead create();
	/**
	 * 
	 * 方法说明：使用反射，根据掺入的类名生成对应的对象
	 *
	 * @param className
	 * @return
	 * @return AbstractFactory
	 */
	static AbstractFactory create(Class clazz){
		
		AbstractFactory factory = null;
		
		try{
			factory = (AbstractFactory) clazz.newInstance();
		}catch(Exception e){
			
			e.printStackTrace();
		}
		return factory;
	}
}
 